package com.example.app;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.app.adapter.MMCAdapter;
import com.example.app.data.MMissionBean;
import com.example.app.database.DBMissionData;

public class MMCheck extends AppCompatActivity {

    private MMissionBean mbean=new MMissionBean();
    private int position;
    private TextView title;
    private ListView listView;
    private Button back,check;
    private DBMissionData data;
    private MMCAdapter mmcAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mmcheck);
        data=new DBMissionData(this);
        init();
    }

    private void init() {
        title=findViewById(R.id.mm_tv);
        title.setText("任务详情");
        listView=findViewById(R.id.mmc_lv);
        Bundle bundle=getIntent().getExtras();
        position=(int) bundle.get("missionNumber");
        mbean=data.getData(position);
        mmcAdapter=new MMCAdapter(mbean,this);
        listView.setAdapter(mmcAdapter);
        back=findViewById(R.id.mm_back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(MMCheck.this,MyMission.class));
                finish();
            }
        });
        check=findViewById(R.id.mmc_check);
        check.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mbean.setIfPass(1);
                data.setPass(position);
                startActivity(new Intent(MMCheck.this,MyMission.class));
                finish();
            }
        });
    }

}